unit wgetitus;

{****************************************************************************}

interface

uses Wincrt,Windos,
      CartoCmds,        (* Contient les def. globales *)
      tit_win,get_win,gmuf_win,aux_win,coul_win;


(*************************** gethff - 3 Nov 90 *****************************)

function get_titus(nomsc:string;var nlig_capt, ncol_capt:integer;
                    var S_tit, S_Sat, S_Capt, S_TitCan :string): integer;

{****************************************************************************}

implementation

(*************************** getbmp - 5 Juin 91 *****************************)

function get_titus(nomsc:string;var nlig_capt, ncol_capt:integer;
                    var S_tit, S_Sat, S_Capt, S_TitCan :string): integer;

const

(* FORMAT D'IMAGE IMAGEPRO bmp *)

     card_capt = 8;

var   ier,i,i1,i2,l,k,n:integer;
      titus : file;
      buf_titus:array[1..512] of byte;
      S_lig,S_col,S_canal,S_prlig,S_prcol,S_date,S_heure : String;


label 989,990,991,992,993,994,995,996,997,998,999;

begin

  get_titus := -1;

  ncol_capt := 0;
  nlig_capt := 0;

  {$I-}

  assign(titus,nomsc);
  reset(titus,1);
  if ioresult <> 0 then begin get_titus := -2; goto 999; end;
(* Type Titus *)
  blockread(titus,buf_titus,512);

  i1 := 1; i2 := 0; S_tit := '';
  for i := i1 to 512 do begin
    i2 := i2 + 1;
    if i2 > 255 then begin close(titus); goto 999; end;
    if char(buf_titus[i]) = '*' then goto 998
      else S_tit := S_tit+char(buf_titus[i]);
  end;

998 :  S_tit := copy(s_tit,1,45);

  i1 := i+1; i2 := 0; S_lig := '';
  for i := i1 to 512 do begin
    i2 := i2 + 1;
    if i2 > 255 then begin close(titus); goto 999; end;
    if char(buf_titus[i]) = '*' then goto 997
      else S_lig := S_lig+char(buf_titus[i]);
  end;

997 :
      _nextpar(strw,S_lig);
      _nextpar(strw,S_lig); val(strw, nlig_capt, erreur);

  i1 := i+1; i2 := 0; S_col := '';
  for i := i1 to 512 do begin
    i2 := i2 + 1;
    if i2 > 255 then begin close(titus); goto 999; end;
    if char(buf_titus[i]) = '*' then goto 996
      else S_col := S_col+char(buf_titus[i]);
  end;

996 :
      _nextpar(strw,S_col);
      _nextpar(strw,S_col); val(strw, ncol_capt, erreur);

  i1 := i+1; i2 := 0; S_sat := '';
  for i := i1 to 512 do begin
    i2 := i2 + 1;
    if i2 > 255 then begin close(titus); goto 999; end;
    if char(buf_titus[i]) = '*' then goto 995
      else S_sat := S_sat+char(buf_titus[i]);
  end;

995 :

  i1 := i+1; i2 := 0; S_canal := '';
  for i := i1 to 512 do begin
    i2 := i2 + 1;
    if i2 > 255 then begin close(titus); goto 999; end;
    if char(buf_titus[i]) = '*' then goto 994
      else S_canal := S_canal+char(buf_titus[i]);
  end;

994 :

  i1 := i+1; i2 := 0; S_prlig := '';
  for i := i1 to 512 do begin
    i2 := i2 + 1;
    if i2 > 255 then begin close(titus); goto 999; end;
    if char(buf_titus[i]) = '*' then goto 993
      else S_prlig := S_prlig+char(buf_titus[i]);
  end;

993 :

  i1 := i+1; i2 := 0; S_prcol := '';
  for i := i1 to 512 do begin
    i2 := i2 + 1;
    if i2 > 255 then begin close(titus); goto 999; end;
    if char(buf_titus[i]) = '*' then goto 992
      else S_prcol := S_prcol+char(buf_titus[i]);
  end;

992 :

  i1 := i+1; i2 := 0; S_capt := '';
  for i := i1 to 512 do begin
    i2 := i2 + 1;
    if i2 > 255 then begin close(titus); goto 999; end;
    if char(buf_titus[i]) = '*' then goto 991
      else S_capt := S_capt+char(buf_titus[i]);
  end;

991 :

  i1 := i+1; i2 := 0; S_date := '';
  for i := i1 to 512 do begin
    i2 := i2 + 1;
    if i2 > 255 then begin close(titus); goto 999; end;
    if char(buf_titus[i]) = '*' then goto 990
      else S_date := S_date+char(buf_titus[i]);
  end;

990 :

  i1 := i+1; i2 := 0; S_heure := '';
  for i := i1 to 512 do begin
    i2 := i2 + 1;
    if i2 > 255 then begin close(titus); goto 999; end;
    if char(buf_titus[i]) = '*' then goto 989
      else S_heure := S_heure+char(buf_titus[i]);
  end;

989 :

  S_TitCan := S_canal+' '+S_Capt+' '+S_Date+' '+S_heure;
  close(titus);
  get_titus := 0;

  {$I-}

999:end;

end.

